<p>To analyse the requests that a system makes the proxy can be used to record all requests and their corresponding responses.</p>

<h3>Retrieve Recorded Requests</h3>

<p>Recorded requests can be retrieved as a list of <a href="#button_retrieve_all_recorded_reqs"><strong>requests</strong></a> received by the proxy in either JSON or Java code.</p>

<button id="button_recorded_reqs" class="accordion title"><strong>Retrieving Recorded Requests Code Examples</strong></button>
<div class="panel title">
    <button id="button_retrieve_all_recorded_reqs" class="accordion">retrieve all recorded requests</button>
    <div class="panel">
        <button class="accordion inner">Java</button>
        <div class="panel">
            <pre class="prettyprint lang-java code"><code class="code">HttpRequest[] recordedRequests = new MockServerClient("localhost", 1080)
    .retrieveRecordedRequests(
        request()
    );</code></pre>
        </div>
        <button class="accordion inner">JavaScript</button>
        <div class="panel">
            <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
    .retrieveRecordedRequests({})
    .then(
        function (recordedRequests) {
            console.log(JSON.stringify(recordedRequests));
        },
        function (error) {
            console.log(error);
        }
    );</code></pre>
        </div>
        <button class="accordion inner">REST API</button>
        <div class="panel">
            <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/retrieve?type=REQUESTS"</code></pre>
        </div>
    </div>
    <button id="button_retrieve_recorded_reqs_using_request_matcher" class="accordion">retrieve recorded requests using request matcher</button>
    <div class="panel">
        <button class="accordion inner">Java</button>
        <div class="panel">
            <pre class="prettyprint lang-java code"><code class="code">HttpRequest[] recordedRequests = new MockServerClient("localhost", 1080)
    .retrieveRecordedRequests(
        request()
            .withPath("/some/path")
            .withMethod("POST")
    );</code></pre>
        </div>
        <button class="accordion inner">JavaScript</button>
        <div class="panel">
            <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).retrieveRecordedRequests({
    "path": "/some/path",
    "method": "POST"
}).then(
    function (recordedRequests) {
        console.log(JSON.stringify(recordedRequests));
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        </div>
        <button class="accordion inner">REST API</button>
        <div class="panel">
            <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/retrieve?type=REQUESTS" -d '{
    "path": "/some/path",
    "method": "POST"
}'</code></pre>
        </div>
    </div>
    <button id="button_retrieve_recorded_reqs_as_java" class="accordion">retrieve recorded requests as java</button>
    <div class="panel">
        <button class="accordion inner">Java</button>
        <div class="panel">
            <pre class="prettyprint lang-java code"><code class="code">String recordedRequests = new MockServerClient("localhost", 1080)
    .retrieveRecordedRequests(
        request()
            .withPath("/some/path")
            .withMethod("POST"),
        Format.JAVA
    );</code></pre>
        </div>
        <button class="accordion inner">REST API</button>
        <div class="panel">
            <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/retrieve?type=REQUESTS&format=JAVA" -d '{
    "path": "/some/path"
}'</code></pre>
        </div>
    </div>
    <button id="button_retrieve_recorded_reqs_as_json" class="accordion">retrieve recorded requests as json</button>
    <div class="panel">
        <button class="accordion inner">Java</button>
        <div class="panel">
            <pre class="prettyprint lang-java code"><code class="code">String recordedRequests = new MockServerClient("localhost", 1080)
    .retrieveRecordedRequests(
        request()
            .withPath("/some/path")
            .withMethod("POST"),
        Format.JSON
    );</code></pre>
        </div>
        <button class="accordion inner">JavaScript</button>
        <div class="panel">
            <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).retrieveRecordedRequests({
    "path": "/some/path",
    "method": "POST"
}).then(
    function (recordedRequests) {
        console.log(JSON.stringify(recordedRequests));
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        </div>
        <button class="accordion inner">REST API</button>
        <div class="panel">
            <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/retrieve?type=REQUESTS&format=JSON" -d '{
    "path": "/some/path"
}'</code></pre>
        </div>
    </div>
</div>

<h3>Retrieve Recorded Expectations</h3>

<p>Recorded requests-response pairs can be retrieved as a list of <a href="#button_retrieve_all_recorded_expectations"><strong>expectations</strong></a> containing the request and response that was proxied in either JSON or Java code.</p>

<p>The list of retrieved expectations can be used to <a href="/mock_server/getting_started.html#setup_expectations">setup expectations</a> in MockServer to support mocking.</p>

<button id="button_recorded_expectations" class="accordion title"><strong>Retrieving Recorded Expectations Code Examples</strong></button>
<div class="panel title">
    <button id="button_retrieve_all_recorded_expectations" class="accordion">retrieve all recorded expectations</button>
    <div class="panel">
        <button class="accordion inner">Java</button>
        <div class="panel">
            <pre class="prettyprint lang-java code"><code class="code">Expectation[] recordedExpectations = new MockServerClient("localhost", 1080)
    .retrieveRecordedExpectations(
        request()
    );</code></pre>
        </div>
        <button class="accordion inner">JavaScript</button>
        <div class="panel">
            <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
    .retrieveRecordedExpectations({})
    .then(
        function (recordedExpectations) {
            console.log(JSON.stringify(recordedExpectations));
        },
        function (error) {
            console.log(error);
        }
    );</code></pre>
        </div>
        <button class="accordion inner">REST API</button>
        <div class="panel">
            <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/retrieve?type=RECORDED_EXPECTATIONS"</code></pre>
        </div>
    </div>
    <button id="button_retrieve_recorded_expectations_using_request_matcher" class="accordion">retrieve recorded expectations using request matcher</button>
    <div class="panel">
        <button class="accordion inner">Java</button>
        <div class="panel">
            <pre class="prettyprint lang-java code"><code class="code">Expectation[] recordedExpectations = new MockServerClient("localhost", 1080)
    .retrieveRecordedExpectations(
        request()
            .withPath("/some/path")
            .withMethod("POST")
    );</code></pre>
        </div>
        <button class="accordion inner">JavaScript</button>
        <div class="panel">
            <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).retrieveRecordedExpectations({
    "path": "/some/path",
    "method": "POST"
}).then(
    function (recordedExpectations) {
        console.log(JSON.stringify(recordedExpectations));
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        </div>
        <button class="accordion inner">REST API</button>
        <div class="panel">
            <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/retrieve?type=RECORDED_EXPECTATIONS" -d '{
    "path": "/some/path",
    "method": "POST"
}'</code></pre>
        </div>
    </div>
    <button id="button_retrieve_recorded_expectations_as_java" class="accordion">retrieve recorded expectations as java</button>
    <div class="panel">
        <button class="accordion inner">Java</button>
        <div class="panel">
            <pre class="prettyprint lang-java code"><code class="code">String recordedExpectations = new MockServerClient("localhost", 1080)
    .retrieveRecordedExpectations(
        request()
            .withPath("/some/path")
            .withMethod("POST"),
        Format.JAVA
    );</code></pre>
        </div>
        <button class="accordion inner">REST API</button>
        <div class="panel">
            <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/retrieve?type=RECORDED_EXPECTATIONS&format=JAVA" -d '{
    "path": "/some/path"
}'</code></pre>
        </div>
    </div>
    <button id="button_retrieve_recorded_expectations_as_json" class="accordion">retrieve recorded expectations as json</button>
    <div class="panel">
        <button class="accordion inner">Java</button>
        <div class="panel">
            <pre class="prettyprint lang-java code"><code class="code">String recordedExpectations = new MockServerClient("localhost", 1080)
    .retrieveRecordedExpectations(
        request()
            .withPath("/some/path")
            .withMethod("POST"),
        Format.JSON
    );</code></pre>
        </div>
        <button class="accordion inner">JavaScript</button>
        <div class="panel">
            <pre class="prettyprint lang-javascript code"><code class="code">var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).retrieveRecordedExpectations({
    "path": "/some/path",
    "method": "POST"
}).then(
    function (recordedExpectations) {
        console.log(JSON.stringify(recordedExpectations));
    },
    function (error) {
        console.log(error);
    }
);</code></pre>
        </div>
        <button class="accordion inner">REST API</button>
        <div class="panel">
            <pre class="prettyprint code"><code class="code">curl -v -X PUT "http://localhost:1080/mockserver/retrieve?type=RECORDED_EXPECTATIONS&format=JSON" -d '{
    "path": "/some/path"
}'</code></pre>
        </div>
    </div>
</div>
